|
|
|
|
|
|
|
In addition, a user can make a form smaller, obscuring some controls. However, if your form is simple enough, you may be able to add some code to the form's Resize event to make it resolution independent. By looking at the Height and Width properties of each control and comparing them to the form's height and width, you can easily add code so that controls will maintain their relative positions when users resize your form. The following code adjusts the sizes of a list box and two command buttons so that their sizes will change with the form: |
|
|
|
|
|
|
|
|
Private Sub Form_Resize()
If Me.Height <= 1365 Then Exit Sub
lstMain.Height = Me.Height - 1365
lstMain.Width = Me.Width - 420
cmdOK.Top = lstMain.Height + 360
cmdOK.Left = lstMain.Width - cmdOK.Width
cmdCancel.Top = cmdOK.Top
cmdCancel.Left = cmdOK.Left - cmdCancel.Width - 120
End Sub |
|
|
|
|
| |
|
|
|
|
For an even better form, change the font size of your controls as the form size changes. |
|
|
|
|
|
|
|
|
|
|
Note that the first line of code in the Resize event exits the event procedure if the form height becomes too small because an error would occur if a negative value were assigned. |
|
|
|
|
|
|
|
|
|
You also can find third-party controls that can be used to add resolution independence to your applications.  |
|
|
|
|
|
|
|
|
|
|
Another customization that can adversely affect your program is the Regional Settings Control Panel, pictured in Figure 18.8. This screen allows users to set their own currency and date format, among other things. If you use these predefined formats in your program, make sure that your variables, database fields, and calculations can handle them. |
|
|
|
|
|
|
|
|
See "Formatting Results," p. 195 |
|
|
|
|
|
|
|
|
Figure 18.8
Make sure your program is prepared
to handle changes users make in
the Regional Settings Control Panel. |
|
|
|
|
|